package com.orange.base.component.biztool.simulateddata.service.impl;

import com.orange.base.component.biztool.simulateddata.service.SimulatedDataEnum;
import com.orange.base.component.biztool.simulateddata.service.SimulatedDataParam;

/**
 * 自定义数组
 *
 * @author biankudingcha
 * @date: 2022-11-09
 * @since 0.5.0
 */
public class CustomArrayStrategy extends AbstractSimulatedData {

    @Override
    public Object getValue(SimulatedDataParam param) {
        if (param.getValue() == null || "".equals(param.getValue())) {
            return null;
        }
        String[] array = param.getValue().split(",");
        int index = getRandomNumber(0, array.length - 1);
        return array[index];
    }

    @Override
    public String getType() {
        return SimulatedDataEnum.CUSTOM_ARRAY.getName();
    }

    @Override
    public String getCaption() {
        return SimulatedDataEnum.CUSTOM_ARRAY.getCaption();
    }

}
